Nested lexers allows use external lexer for the defined text space. For example in HTML we want that script will be highlighted with the corresponded lexer (java script, vb script, perl script, ...).
Sub lexer rules are intended for this purpose.
Because Sub lexer rules are derived from TRuleCollectionItem thay supports common properties:Parent block, Strict parent block, Not a parent, Always enabled. See "Common for Styles and Rules".
Style is applied to all text space where this nested lexer will act. If you want some rules of lexer will be enabled in the text space of nested lexer you must set "Always enabled" property of that rules to TRUE.
Sub lexer combo box allows you to select nested lexer. It containes all lexers with the same Owner, i.e. if you have two lexer on the form, for each of them they will present in sub lexer combo.
To detect text space two regular expression are used: "Start condition" and "End condition".
Text space will be from the end of the "Start condition" to th start of the end condition.
For example, we include Assembler lexer into Pascal.
Sub lexer = "Pascal"
Start condition = "asm"
End condition = "end"
In this case text space will be from the next character after "asm" to the previous character before "end".
If text space must start from the begin of text set property "Start at the begin of text". Nested lexer starts at the begin of text.
If text space must be closed at end of text set property "End at the end of text". Nested lexer closes at the end of text.
Also if you want to extend some lexer without modifying it, you can do this:
1. Create new lexer.
2. Create "Sub lexer" rule for the base lexer from start to end of text.
3. Create new rules and mark them as "Always enabled".
So you create inherited lexer which have all rules of base lexer plus rules defined in the derived lexer.